<template>
  <div>
    <div style="margin: 16px">
      <input
        class="van-button van-button--info van-button--normal van-button--block van-button--round"
        type="button"
        value="注册"
        @click="onSubmit"
      />
    </div>
  </div>
</template>

<script>
import Fingerprint2 from "fingerprintjs2";
export default {
  name: "formVail",
  data() {
    return {
      username: "",
      password: "",
      confirmPassword: "",
      submitFlag: false,
      fingerprintCode: "",
    };
  },
  methods: {
    onSubmit() {
      let that = this;
      let options = (Fingerprint2.Options = {
        excludes: {
          language: true,
          colorDepth: true,
          deviceMemory: true,
          pixelRatio: true,
          availableScreenResolution: true,
          timezoneOffset: true,
          timezone: true,
          sessionStorage: true,
          localStorage: true,
          indexedDb: true,
          addBehavior: true,
          openDatabase: true,
          cpuClass: true,
          doNotTrack: true,
          plugins: true,
          canvas: true,
          webglVendorAndRenderer: true,
          adBlock: true,
          hasLiedLanguages: true,
          hasLiedResolution: true,
          hasLiedOs: true,
          hasLiedBrowser: true,
          touchSupport: true,
          audio: false,
          enumerateDevices: true,
          hardwareConcurrency: true,
        },
      });
      Fingerprint2.get(options, (components) => {
        const value = components.map((component, index) => {
          if (index === 0) {
            //把微信浏览器里UA的wifi或4G等网络替换成空,不然切换网络会ID不一样
            return component.value.replace(/\bNetType\/\w+\b/, "");
          }
          return component.value;
        });
        // 生成最终id murmur
        const murmur = Fingerprint2.x64hash128(value.join(""), 31);
        that.fingerprintCode = murmur;
      });
      setTimeout(() => {
        this.$dialog.alert({
          message: this.fingerprintCode,
          theme: "round-button",
        });
      }, 500);
    },
  },
};
</script>

<style>
</style>
